#include <cstdio> // for sscanf, snprintf, vprintf, SEEK_SET
#include <cstdlib> // for free
#include <cstring> // for memset
-#include <ctime> // for time, time_t
#include <QByteArray> // for QByteArray
#include <QChar> // for QChar
return ((unsigned)be_read16(p+2) << 16) | ((unsigned)be_read16(p));
}
-time_t
-SkytraqBase::gpstime_to_timet(int week, int sec) const
+QDateTime
+SkytraqBase::gpstime_to_qdatetime(int week, int sec) const
{
/* Notes:
* * week rollover period can be specified using option
* * overflow of sec into next week is allowed
* (i.e. sec >= 7*24*3600 = 604800 is allowed)
*/
- time_t gps_timet = 315964800; /* Jan 06 1980 0:00 UTC */
+ qint64 gps_timet = 315964800; /* Jan 06 1980 0:00 UTC */
int week_rollover = xstrtoi(opt_gps_week_rollover, nullptr, 10);
if (week_rollover < 0) {
- int current_week = (time(nullptr)-gps_timet)/(7*SECONDS_PER_DAY);
+ int current_week = (QDateTime::currentSecsSinceEpoch() - gps_timet)/
+ (7*SECONDS_PER_DAY);
week_rollover = current_week/1024 - (week > current_week%1024 ? 1 : 0);
}
gps_timet += (week+week_rollover*1024)*7*SECONDS_PER_DAY + sec;
int override = xstrtoi(opt_gps_utc_offset, nullptr, 10);
if (override) {
gps_timet -= override;
- return gps_timet;
+ return QDateTime::fromSecsSinceEpoch(gps_timet);
}
/* leap second compensation: */
// Future: Consult http://maia.usno.navy.mil/ser7/tai-utc.dat
// use http://www.stevegs.com/utils/jd_calc/ for Julian to UNIX sec
- return gps_timet; /* returns UTC time */
+ return QDateTime::fromSecsSinceEpoch(gps_timet); /* returns UTC time */
}
void
wpt->latitude = lat;
wpt->longitude = lon;
wpt->altitude = alt;
- wpt->SetCreationTime(gpstime_to_timet(st->gps_week, st->gps_sec));
+ wpt->SetCreationTime(gpstime_to_qdatetime(st->gps_week, st->gps_sec));
return wpt;
}
#ifndef SKYTRAQ_H_INCLUDED_
#define SKYTRAQ_H_INCLUDED_
-#include <QString> // for QString
-#include <QVector> // for QVector
+#include <QDateTime> // for QDateTime
+#include <QString> // for QString
+#include <QVector> // for QVector
-#include <cstdint> // for uint8_t, int32_t, uint32_t, uint16_t, int16_t
-#include <ctime> // for time_t
+#include <cstdint> // for uint8_t, int32_t, uint32_t, uint16_t, int16_t
-#include "defs.h" // for arglist_t, ARGTYPE_INT, ff_cap, ARG_NOMINMAX, ARGTYPE_STRING, ff_cap_read, ARGTYPE_BOOL, ff_cap_none, ff_type, ARGTYPE_OUTFILE, ff_type_serial, Waypoint, ff_type_file, route_head
-#include "format.h" // for Format
-#include "gbfile.h" // for gbfile
+#include "defs.h"
+#include "format.h" // for Format
+#include "gbfile.h" // for gbfile
class SkytraqBase
int skytraq_configure_logging() const;
int skytraq_get_log_buffer_status(uint32_t* log_wr_ptr, uint16_t* sectors_free, uint16_t* sectors_total) const;
static unsigned int me_read32(const unsigned char* p);
- time_t gpstime_to_timet(int week, int sec) const;
+ QDateTime gpstime_to_qdatetime(int week, int sec) const;
static void ECEF_to_LLA(double x, double y, long int z, double* lat, double* lon, double* alt);
static void state_init(read_state* pst);
Waypoint* make_trackpoint(read_state* st, double lat, double lon, double alt) const;